package com.example.attendancesystem_1_8.backendInterface;

import com.alibaba.fastjson.JSONObject;

public class SignIn
{
    private static final String URL="http://47.96.144.238:8080/signin/signin";


    /**
     * 用户添加一条打卡记录
     * @param account 账号
     * @param password 密码
     * @param year 年
     * @param month 月
     * @param day 日
     * @param hour 小时
     * @param minute 分钟
     * @param address 打卡地址
     */
    public static int signIn(String account,String password,int year,int month,int day,int hour,int minute,String type, String address)
    {
        JSONObject body=new JSONObject();
        body.put("account",account);
        body.put("password",password);
        body.put("year",year);
        body.put("month",month);
        body.put("day",day);
        body.put("hour",hour);
        body.put("minute",minute);
        body.put("type", type);
        body.put("address",address);

        JSONObject ans=JSONObject.parseObject(HttpRequest.sendPost(URL,body.toString()));

        if(ans.getString("success").equals("true"))
        {
            System.out.println("打卡成功");
            return 1;
        }
        else
        {
            System.out.println("打卡失败");
            return 0;
        }

    }


    public static void main(String[] args)
    {
        //signIn("123456","654646",45,45,45,45,45,"asd");
        //signIn("123456","654321",2020,12,1,45,54,"whu");




    }


}
